import { defineStore } from 'pinia';
import { ref, computed } from 'vue';
const useSettingStore = defineStore(
  'setting',
  () => {
    const asideActive = ref(false); // active 侧边栏为半展开状态
    const asideExpand = ref(false); // expand 侧边栏为全展开状态

    const currentMenuItem = ref(''); // 保存当前激活的菜单项

    const expand = computed(() => asideActive.value || asideExpand.value);

    const setAsideFold = () => {
      asideActive.value = false;
      asideExpand.value = false;
    };

    const setAsideExpand = () => {
      asideExpand.value = true;
      asideActive.value = true;
    };

    const setAsideActive = () => {
      asideActive.value = true;
      asideExpand.value = false;
    };

    return {
      expand,
      asideActive,
      asideExpand,
      currentMenuItem,
      setAsideFold,
      setAsideActive,
      setAsideExpand,
    };
  },
  {
    persist: true, // 开启持久化存储
  }
);

export default useSettingStore;
